//获取URL传递的参数
// function getParm(word){
//       var url=window.location.search;//获取url参数
//       url=url.substr(1,url.length);
//       if(url.indexOf('&')==-1){
//         brr=url.split('=');
//             if(brr[0]==word){
//                return brr[1];
//             }
//       }else{
//         var arr=url.split('&');
//         var brr='';
//         for(var i=0;i<arr.length;i++){
//             brr=arr[i].split('=');
//             if(brr[0]==word){
//                 return brr[1];
//             }
//         }   
//        } 
//     }
// var goods_id=getParm('goods_id'); 
//测试，需要通过页面获取goods_id 和order_id
var goods_id=1534; 
// var order_id=getParm('order_id');   
//获取商品信息
var userid=myinfo['userid'];
var random=myinfo['random'];
var ht='';
$.ajax({ 
      data:{goods_id:goods_id},
      type:'post',  
      url : myconfig['api']+'goods_show',  
      dataType : 'json',  
      jsonp:"jsoncallback",  
      success  : function(data) { 
        var money=parseInt(data.lists.goods_price)+parseInt(data.lists.goods_bonus); 
        var end_time=data.lists.end_time;
        console.debug(data.lists);
        ht+='<div class="part part1">';
        ht+='<div class="part1L">';
        ht+='<img src=http://localhost/'+data.lists.thumb+'>';
        ht+='</div>';
        ht+='<div class="part1R">';
        ht+='<h3 class="yc">'+data.lists.title+'</h3>';
        ht+='<p class="yc">下单：<b>￥'+data.lists.goods_price+'</b>';
        if(data.lists.protype==3){
        ht+='<em>红包任务</em>';
        }else if(data.lists.protype==2){
        ht+='<em>拍A发B</em>';
        }        
        ht+='<p class="yc">返还：<b>￥'+money+'</b>（含红包<b>￥'+data.lists.goods_bonus+'</b>）</p>';
        ht+='</div>';
        ht+='</div>';
        ht+='<div class="order_xq_tip">';
        ht+='<p>未在<b><span id="day_show"></span>天<span id="hour_show"></span>小时<span id="minute_show"></span>分<span id="second_show"></span>秒</b>前下单，将失去资格！</p>';
        ht+='</div>';
        ht+='<div class="part part2">';
        ht+='<h3><span>请为试用品打分</span></h3>';
        ht+='<select class="star">';
        ht+='<option value=5>★★★★★完全满意,太完美了</option>';
        ht+='<option value=4>★★★★比较满意,离完美差点</option>';
        ht+='<option value=3>★★★一般满意,还有待提高</option>';
        ht+='<option value=2>★★非常不满意,有待提高</option>';
        ht+='<option value=1>★完全不满意,有点失望</option>';
        ht+='</select>';
        ht+='</div>';
        ht+='<div class="order_xq_tip">';
        ht+='<p>试用商品图</p>';
        ht+='</div>';
        ht+='<div class="part">';
        ht+='<div class="file_img"><img src="/images/shai_img.jpg"></div>';
        ht+="<input type='file' id='up_report'>";
        ht+='</div>';
        ht+='<div class="order_xq_tip">';
        ht+='<p>试用过程及感受</p>';
        ht+='</div>';
        ht+='<div class="part">';
        ht+='<textarea id="report_xq" placeholder="分享下试用心得"></textarea>';
        ht+='</div>';
        ht+='<div class="save">提交试用报告</div>';
        $('.order_report').append(ht);
        var data0=data.lists;
        timer(end_time);    
        $('.save').click(function(){
            var star_level=$('.star').val();
            var report_xq=$('#report_xq').val();
        console.debug(goods_id,star_level,report_xq);
})
                         
      },
      error: function(data) {                              
            alert('出错了');                             
      },  
});


function timer(end_time){
    
    tim=window.setInterval(function(){

    var intDiff=end_time-parseInt(new Date().getTime()/1000);
    var day=0,
        hour=0,
        minute=0,
        second=0;//时间默认值        
    if(intDiff > 0){
        day = Math.floor(intDiff / (60 * 60 * 24));
        hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
        minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
        second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
    
        if (minute <= 9) minute = '0' + minute;
        if (second <= 9) second = '0' + second;    
        $('#day_show').html(day);
        $('#hour_show').html(hour);
        $('#minute_show').html(minute);
        $('#second_show').html(second);
        
    }

    }, 1000);
} 